window.toggle = true;

function animate(obj,target,callback){
    // obj是移动物体
    // target是目标移动距离
    // callback是回调
    if(toggle){
        toggle = false;
        obj.timer = setInterval(function(){
            var step = (target - obj.offsetLeft)/5;
            step = step>0?Math.ceil(step):Math.floor(step);
            if(obj.offsetLeft == target){
                clearInterval(obj.timer);
                window.toggle = true;
                if(callback){
                    callback();
                }
            }
            obj.style.left = obj.offsetLeft + step + "px";
        },15)
    }
}